import 'package:flutter/material.dart';

import 'Navigator/NavigatorDemo1.dart';

class WNavigator extends StatefulWidget {
  @override
  _WNavigatorState createState() => _WNavigatorState();
}

class _WNavigatorState extends State<WNavigator> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Navigator"),
        centerTitle: true,
      ),
      body: Align(
        child: Column(
          children: <Widget>[
            SizedBox(
              height: 20,
            ),
            Container(
              padding: EdgeInsets.all(10),
              decoration: BoxDecoration(
                  color: Colors.red,
                  border: Border.all(color: Colors.black, width: 2),
                  borderRadius: BorderRadius.all(Radius.circular(30))),
              child: InkWell(
                onTap: () {
                  Navigator.push(context, MaterialPageRoute(builder: (context) {
                    return NavigatorDemo1();
                  }));
                },
                child: Text(
                  "进入下一个页面",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            OutlineButton(
              child: Text('传值进入下一个页面'),
              onPressed: () async {
                var result = await Navigator.push(context,
                    MaterialPageRoute(builder: (context) {
                  return NavigatorDemo1(
                    content: "我是传递的值{id:20,content:Flutter}",
                  );
                }));
                print("从上一个页面返回的值是:${result}");
              },
            )
          ],
        ),
      ),
    );
  }
}
